// $('.ghmz-hzfl-box1').children().each(function(index,value){
//     $('.ghmz-hzfl-box1').children().value.attr('hzfl',index)
// console.log(index)
//  $('.ghmz-hzfl-box1').children()
// })
// for(i=0;i<$('.ghmz-hzfl-box1').children().length;i++){
//     $('.ghmz-hzfl-box1').children().eq([i]).attr('hzfl',$('.ghmz-hzfl-box1').children().eq([i]).text())
//     $('.ghmz-hzfl-box1').children().eq([i]).click(function(){
//         alert($(this).attr('hzfl'))
//     })
// }
// 分类显示和隐藏
$('.ghmz-hzfl-box1').mouseover(function () {
    $('.ghmz-hzfl-ul1 ').css({
        display: 'block'
    })
})
$('.ghmz-hzfl-ul1').mouseover(function () {
    $('.ghmz-hzfl-ul1 ').css({
        display: 'block'
    })
})
$('.ghmz-hzfl-ul1').mouseout(function () {
    $('.ghmz-hzfl-ul1 ').css({
        display: 'none'
    })
})
$('.ghmz-hzfl-box1').mouseout(function () {
    $('.ghmz-hzfl-ul1 ').css({
        display: 'none'
    })
})
for (i = 0; i < $('.ghmz-hzfl-ul1 li').length; i++) {
    $('.ghmz-hzfl-ul1 li').eq([i]).click(function () {
        $('.ghmz-hzfl-box1-1-span').text($(this).text())
        $('.ghmz-hzfl-box1-1').css({
            display: 'block'
        })
    })
}
// 品牌分类
for (i = 0; i < $('.ghmz-ppfl-gd div').length; i++) {
    $('.ghmz-ppfl-gd div').eq([i]).hover(function () {
        $(this).css({
            border: 'solid red 1px'
        })
    }, function () {
        $(this).css({
            border: 'solid #000 1px'
        })
    })
}
$('.ghmz-ppfl-gd-zk').click(function () {
    $('.ghmz-ppfl').toggleClass('ghmz-ppfl-zj')
})
// 数据渲染
$.getJSON('../mock/beauty.json', function (data) {
    var ty3 = ''
    var ty2 = data[0].beauty
    //  console.log(ty2)
    for (i = 0; i <= 3; i++) {
        // console.log(ty2[i])
        ty3 += `<li>
  <div><img src="${ ty2[i].url[0] }"></div>
  <div class="ghmz-xr-1"><p>${ ty2[i].goods_name }</p></div>
  <div><h5>￥${ ty2[i].goods_price }</h5></div>
  <div class="ghmz-xr-gm">立即购买</div>
  </li>`
    }
    $('.ghmz-box-2').html(ty3);
    var ty4 = '';
    for (var i = 0; i < ty2.length; i++) {
        ty4 += `<li class="ghmz-dxr-li index=${ i }">
    <div><img src="${ ty2[i].url[0] }"></div>
   `
        for (var j = 0; j < $(ty2)[i].url.length; j++) {
            ty4 += `
        <img src="${ ty2[i].url[j] }" width=30px" class="ghmz-dxr-li-box1-img">
    `
        }
        ty4 += `
   <div class="ghmz-dxr-li-box2">￥${ ty2[i].goods_price }</div>
   `
        ty4 += `
   <div class="ghmz-dxr-li-box3">已售${ ty2[i].sales_volume }</div>
   `
        ty4 += `
   <div class="ghmz-dxr-li-box4">${ ty2[i].goods_name }</div>
   `
        ty4 += `
   <div class="ghmz-dxr-li-box5">${ ty2[i].super }</div>
   <div style="height: 20px;" class="ghmz-dxr-li-box6">
   <p><span><input type="checkbox" style="margin-left:5px" tlue=${ i } class="ghmz-db">对比</span><span><input type="checkbox" style="margin-left:5px">收藏</span><span><input type="checkbox" style="margin-left:5px">加入购物车</span></p>
   </div>
   `
        ty4 += '</li>';

    }
    // console.log(ty4);

    $('.ghmz-dxr-ul').html(ty4);
    $('.ghmz-dxr-li-box1-img').mouseover(function () {
        $(this).parent().children().eq(0).children().attr('src', $(this).attr('src'))
    })
    // 对比-----
    $('.ghmz-dbhz-sc-p1').click(function () {
        $('.ghmz-dbhz').css({
            // display:"none",
            opacity: 0,
        })
    })
    var ty56 = -1
    $(".ghmz-db").click(function () {
        $('.ghmz-dbhz').css({
            // display:"block",
            opacity: 1,
        })
        var ty52 = data[0].beauty;
        // console.log(ty52)
        var ty53 = $(this).attr('tlue')
        var ty54 = ""
        ty56++
        ty52.forEach(function (value, index) {
            if (index == ty53) {
                // console.log(value)
                ty54 = `<li>
<div class="ghmz-dbhz-ul1-box1">
<img src=${ value.url }>
</div>
<div class="ghmz-dbhz-ul1-box2">
<p>${ value.goods_name }</p>
<p>￥${ value.goods_price }<span class="ghmz-dbhz-sc1">删除</span></p>
</div>
</li>`
            }
            if (ty56 == 4) {
                alert('最多只能对比4个')
                ty56 = -1
            }
        })
        $('.ghmz-dbhz-ul1').children().eq(ty56).replaceWith(ty54)
        console.log($('.ghmz-dbhz-sc1'))
        $('.ghmz-dbhz-sc1').click(function () {
            ty56--
            console.log(ty56)
        })

    })

    // 分类渲染---价格
    // ---------------------------
    function fun1(ty12) {
        var ty13 = ''
        for (i = 0; i <= 3; i++) {
            // console.log(ty2[i])
            ty13 += `<li>
      <div><img src="${ ty12[i].url[0] }"></div>
      <div class="ghmz-xr-1"><p>${ ty12[i].goods_name }</p></div>
      <div><h5>￥${ ty12[i].goods_price }</h5></div>
      <div class="ghmz-xr-gm">立即购买</div>
      </li>`
        }
        $('.ghmz-box-2').html(ty13);
        var ty4 = '';
        for (var i = 0; i < ty12.length; i++) {
            ty4 += `<li class="ghmz-dxr-li index=${ i }">
         <div><img src="${ ty12[i].url[0] }"></div>
        `
            for (var j = 0; j < $(ty12)[i].url.length; j++) {
                ty4 += `
             <img src="${ ty12[i].url[j] }" width=30px" class="ghmz-dxr-li-box1-img">
         `
            }
            ty4 += `
        <div class="ghmz-dxr-li-box2">￥${ ty12[i].goods_price }</div>
        `
            ty4 += `
        <div class="ghmz-dxr-li-box3">已售${ ty12[i].sales_volume }</div>
        `
            ty4 += `
        <div class="ghmz-dxr-li-box4">${ ty12[i].goods_name }</div>
        `
            ty4 += `
        <div class="ghmz-dxr-li-box5">${ ty12[i].super }</div>
        <div style="height: 20px;" class="ghmz-dxr-li-box6">
        <p><span><input type="checkbox" style="margin-left:5px">对比</span><span><input type="checkbox" style="margin-left:5px">收藏</span><span><input type="checkbox" style="margin-left:5px">加入购物车</span></p>
        </div>
        `
            ty4 += '</li>';

        }
        // console.log(ty4);

        $('.ghmz-dxr-ul').html(ty4);
        $('.ghmz-dxr-li-box1-img').mouseover(function () {
            $(this).parent().children().eq(0).children().attr('src', $(this).attr('src'))
        })
    }
    // 价格
    $('.ghmz-sjxr-box1-ul-li5').click(function () {
        var ty12 = data[0].beauty;
        ty12.sort(function (a, b) {
            return a.goods_price - b.goods_price
        })
        fun1(ty12)
        fun2(ty12)
        // console.log(ty2)
    })
    //  评论数
    $('.ghmz-sjxr-box1-ul-li4').click(function () {
        // alert('nn')
        var ty13 = data[0].beauty;
        ty13.sort(function (a, b) {
            return b.comment_num - a.comment_num
        })
        fun1(ty13)
        fun2(ty13)
        // console.log(ty2)
    })
    // 销量
    $('.ghmz-sjxr-box1-ul-li2').click(function () {
        // alert('nn')
        var ty20 = data[0].beauty;
        ty20.sort(function (a, b) {
            return a.sales_volume - b.sales_volume
        })
        fun1(ty20)
        fun2(ty20)
        // console.log(ty2)
    })
    function fun3(ty30) {
        var ty141 = ""
        for (i = 0; i < ty30.length; i++) {
            var zysp = $('[value="商创自营"]').val()
            if (ty30[i].super === zysp) {
                console.log(ty30[i])
                ty141 += `<li class="ghmz-dxr-li index=${ i }">
                    <div><img src="${ ty30[i].url[0] }"></div>
                    `
                for (j = 0; j < ty30[i].url.length; j++) {
                    ty141 += `
                        <img src="${ ty30[i].url[j] }" width=30px" class="ghmz-dxr-li-box1-img">
                    `
                }
                ty141 += `
                    <div class="ghmz-dxr-li-box2">￥${ ty30[i].goods_price }</div>
                    `
                ty141 += `
                    <div class="ghmz-dxr-li-box3">已售${ ty30[i].sales_volume }</div>
                    `
                ty141 += `
                    <div class="ghmz-dxr-li-box4">${ ty30[i].goods_name }</div>
                    `
                ty141 += `
                    <div class="ghmz-dxr-li-box5">${ ty30[i].super }</div>
                    <div style="height: 20px;" class="ghmz-dxr-li-box6">
                    <p><span><input type="checkbox" style="margin-left:5px">对比</span><span><input type="checkbox" style="margin-left:5px">收藏</span><span><input type="checkbox" style="margin-left:5px">加入购物车</span></p>
                    </div>
                    `
                ty141 += '</li>'
                $('.ghmz-dxr-ul').html(ty141);
            }
        }
    }
    //  小图的商创自营封装函数
    function fun4(ty30) {
        var ty141 = ""
        for (i = 0; i < ty30.length; i++) {
            var zysp = $('[value="商创自营"]').val()
            if (ty30[i].super === zysp) {
                console.log(ty30[i])
                ty141 += `<li class="ghmz-dxr-li1 index=${ i }">
                <div class="xtdiv1"><img src="${ ty30[i].url[0] }"></div>
               `
                ty141 += `
               <div class="xtdiv2">${ ty30[i].goods_name }
               <p><span>销量${ ty30[i].sales_volume }</span>
               <span>评价${ ty30[i].comment_num }</span></p>
               </div>
               `
                ty141 += `
               <div class="xtdiv3">${ ty30[i].super }</div>
               `
                ty141 += `
               <div class="xtdiv4">￥${ ty30[i].goods_price }</div>
               <div style="height: 20px;" class="xtdiv5">
            <p><span><input type="checkbox" style="margin-left:5px">对比</span><span><input type="checkbox" style="margin-left:5px">收藏</span><span><input type="checkbox" style="margin-left:5px">加入购物车</span></p>
            </div>
               `
                ty141 += `</li>`
                $(".ghmz-dxr-ul1").html(ty141)
                // $('.ghmz-dxr-ul').html(ty141);
            }
        }
    }
    $('[value="商创自营"]').click(function () {
        var ty30 = data[0].beauty;
        fun3(ty30)
        fun4(ty30)
    })

    //  默认
    $('.ghmz-sjxr-box1-ul-li1').click(function () {
        // alert('nn')
        var ty21 = data[0].beauty;
        ty21.sort(function (a, b) {
            return a.id - b.id
        })
        fun1(ty21)
        fun2(ty21)
        // console.log(ty2)
    })
    //小图
    function fun2(date) {
        var ty12 = data[0].beauty;
        var ty41 = ""
        for (var i = 0; i < ty12.length; i++) {
            ty41 += `<li class="ghmz-dxr-li1 index=${ i }">
            <div class="xtdiv1"><img src="${ ty12[i].url[0] }"></div>
           `
            ty41 += `
           <div class="xtdiv2">${ ty12[i].goods_name }
           <p><span>销量${ ty12[i].sales_volume }</span>
           <span>评价${ ty12[i].comment_num }</span></p>
           </div>
           `
            ty41 += `
           <div class="xtdiv3">${ ty12[i].super }</div>
           `
            ty41 += `
           <div class="xtdiv4">￥${ ty12[i].goods_price }</div>
           <div style="height: 20px;" class="xtdiv5">
        <p><span><input type="checkbox" style="margin-left:5px">对比</span><span><input type="checkbox" style="margin-left:5px">收藏</span><span><input type="checkbox" style="margin-left:5px">加入购物车</span></p>
        </div>
           `
            ty41 += `</li>`
            $(".ghmz-dxr-ul1").html(ty41)
        }
        // $(".ghmz-dxr-ul1").html(ty41)
    }
    $('.ghmz-sjxr-span-s1').click(function () {
        fun2()
        $('.ghmz-dxr-ul1').css({
            display: "block",
        })
        $('.ghmz-dxr-ul').css({
            display: "none",
        })
        return false
    })
    $('.ghmz-sjxr-span-s2').click(function () {
        $('.ghmz-dxr-ul').css({
            display: "block",
        })
        $('.ghmz-dxr-ul1').css({
            display: "none",
        })
    })
    // console.log(ty2.super)
})
// =========================================
// 头部
// 横幅
$('.cha').click(function () {
    $(this).parents('.banner').css('display', 'none')
})

// 分类
$('.classify-right>li>a').click(function () {
    $(this).css('color', 'red')
})


// 郑州市
$('.city').mouseover(function () {
    $(this).css('background-color', '#fff');
    $(this).css('border-right', '1px solid #ccc');
    $(this).css('border-left', '1px solid #ccc');
    $(this).next('.two').css('display', 'block');
})
$('.city').mouseout(function () {
    $(this).css('background-color', '#eee');
    $(this).css('border', 'none');
    $(this).next('.two').css('display', 'none');
})


// 网站导航
$('.last').mouseover(function () {
    $(this).css('background-color', '#fff');
    $(this).css('border-right', '1px solid #ccc');
    $(this).css('border-left', '1px solid #ccc');
    $(this).next('.layer').css('display', 'block');
})
$('.last').mouseout(function () {
    $(this).css('background-color', '#eee');
    $(this).css('border', 'none');
    $(this).next('.layer').css('display', 'none');
})

// 购物车
$('.car').mouseover(function () {
    $(this).css('border-bottom', '1px solid #fff');
    $(this).next('.car-son').css('display', 'block')
})
$('.car').mouseout(function () {
    $(this).css('border-bottom', '1px solid #ccc');
    $(this).next('.car-son').css('display', 'none')
})
// 侧边栏
$('.tianchu').click(function () {
    $('.i_avatar_box').css('display', 'block')
    $('.i_menbu').css('display', 'block')
})
$('.xiaoshi').click(function () {
    $('.i_avatar_box').css('display', 'none')
    $('.i_menbu').css('display', 'none')
})

/* 回到顶部 */
$(window).scroll(function () {
    console.log(11);
    // 监听滚动条
    console.log($(window).scrollTop());
    if ($(window).scrollTop() >= 100) {
        $(".fanhui").fadeIn(600);
    } else {
        $(".fanhui").fadeOut(600);
    }
})

$(".fanhui").click(function () {
    $("html").animate({
        scrollTop: 0
    }, 1000)
})
// $('.ibar_closebtn').click(function () {
//     $(".i_accen").animate({
//         right: -270
//     }, 500, "linear")
// })
$(".wkuan").click(function () {
    // toggle(speed, easing, callback)
    $(".i_go-shop").toggle(500, "swing", function () {
    })
})

// $('.ibar_closebtn').click(function () {
//     $(".i_go-shop").css('display', 'none')
// })
$(".brand-con-a li").mouseover(function () {
    $(this).addClass("cur").siblings().removeClass("cur");
})
// 点击多选出现的区域
var sou = 0;
$(".icon-plus").click(function () {
    if (sou == 0) {
        $(this).children().text("-收起")
        $(".brand-cen").hide()
        $(".brand-con-1").show()
        sou = 1
        console.log(sou);
    } else if (sou != 0) {
        $(this).children().text("+更多")
        $(".brand-cen").show()
        $(".brand-con-1").hide()
        sou = 0
        console.log(sou);
    }
})
// 点击之后变成勾对
var pin = 0;
$(".brand-con-b li").click(function () {
    if (pin == 0) {
        $(this).css("background", "url(../commonImg/dui3.png) 0 5px no-repeat")
        $(this).css("color", "red")
        pin = 1;
    } else if (pin != 0) {
        $(this).css("background", "url(../commonImg/dui1.png) 0 5px no-repeat")
        $(this).css("color", "#555555")
        pin = 0;
    }
})
$('.sellerlist .pages div').hover(function () {
    $(this).addClass('Bianse1');
}, function () {
    $(this).removeClass('Bianse1');
})
$('.lol').click(function () {
    $(this).addClass('cur').siblings().removeClass('cur');
});
$('.next').click(function () {
    $(this).prev().addClass('cur');
    $('.prev').next().removeClass('cur');
    $('.steet-pubu2').addClass('showww').siblings().removeClass('showww');
    $('#gallery-wrapper').addClass('hideee');
    $('html').animate({
        scrollTop: 500
    }, 200);
});
$('.prev').click(function () {
    $(this).next().addClass('cur');
    $('.next').prev().removeClass('cur');
    $('.steet-pubu2').addClass('hideee');
    $('#gallery-wrapper').addClass('showww').siblings().removeClass('showww');
    $('html').animate({
        scrollTop: 500
    }, 200);
});
